package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Permission;
import com.itheima.health.pojo.User;
import com.itheima.health.vo.RoleVo;
import com.itheima.health.vo.UserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

public interface UserMapper extends BaseMapper<User> {
    @Select("select  username,password,id from t_user where username = #{username}")
    UserVO findUserInfoByUsername(@Param("username") String username);

    @Select("select tr.id,tr.KEYWORD " +
            "from t_user_role tur ,t_role tr " +
            "WHERE tur.ROLE_ID=tr.ID " +
            "and tur.USER_ID=#{uid}")
    List<RoleVo> findRolesByUid(@Param("uid") Integer uid);

    @Select("select tp.KEYWORD " +
            "from t_role_permission trp ,t_permission tp " +
            "where trp.PERMISSION_ID=tp.ID AND " +
            "trp.ROLE_ID=#{roleId}")
    List<Permission> findPermission(@Param("roleId") Integer roleId);
}
